﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoTestingFramework.Core.Configurations
{
    public class WebDriverConfiguration
    {
        private static WebDriverConfiguration _current = new WebDriverConfiguration();

        public static WebDriverConfiguration Current
        {
            get { return WebDriverConfiguration._current; }
        }


        private IWebDriverSettings _settings = new WebDriverSettings();

        public IWebDriverSettings Settings
        {
            get { return _settings; }
            set { _settings = value; }
        }

        public WebDriverConfiguration Configure(IWebDriverSettings settings)
        {
            _settings = settings;
            return this;
        }

        public WebDriverConfiguration DriverCommandTimeout(TimeSpan commandTimeout)
        {
            if (commandTimeout == null)
                throw new ArgumentNullException("commandTimeout");

            var defaultValues = new WebDriverSettings();

            this.Settings.CommandTimeout = commandTimeout > defaultValues.CommandTimeout
                                                            ? commandTimeout
                                                            : defaultValues.CommandTimeout;
            return this;
        }
    }
}
